package com.shuhua.taskServer.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shuhua.pojo.entity.TaskHandle;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;

@Mapper
public interface TaskHandleMapper extends BaseMapper<TaskHandle> {
    @Select("SELECT h.*, r.resourcesid, r.fileurl, r.createdat FROM taskhandle h LEFT JOIN taskhandleresource r ON h.handleid = r.handleid WHERE h.handleid = #{handleId}")
    List<Map<String, Object>> selectHandleWithResourcesByHandleId(@Param("handleId") Long handleId);

    @Select("SELECT h.*, r.resourcesid, r.fileurl, r.createdat FROM taskhandle h LEFT JOIN taskhandleresource r ON h.handleid = r.handleid WHERE h.taskid = #{taskId}")
    List<Map<String, Object>> selectHandleWithResourcesByTaskId(@Param("taskId") Long taskId);

    @Select("SELECT h.*, r.resourcesid, r.fileurl, r.createdat FROM taskhandle h LEFT JOIN taskhandleresource r ON h.handleid = r.handleid ORDER BY h.handleid ASC, r.resourcesid ASC")
    List<Map<String, Object>> selectAllHandleWithResources();
} 